package com.hey.snmp.utils;

import org.snmp4j.PDU;
import org.snmp4j.event.ResponseEvent;
import org.snmp4j.event.ResponseListener;
import org.snmp4j.smi.VariableBinding;

import java.util.List;

public class SnmpResponse implements ResponseListener {

    public List list;

    public List getList() {
        return list;
    }

    public void setList(List list) {
        this.list = list;
    }

    @Override
    public void onResponse(ResponseEvent responseEvent) {
        // 处理响应
        PDU response = responseEvent.getResponse();
        if (response == null) {
            System.out.println("response is null, request time out");
        }else {
            for (int i = 0; i < response.size(); i++) {
                VariableBinding vb = response.get(i);
                list.add(vb.getVariable());
                System.out.println(vb.getOid() + " = " + vb.getVariable());
            }
        }
    }
}
